<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:fmt="http://java.sun.com/jsp/jstl/fmt">
<head>
    <meta charset="UTF-8">
    <title>upload bolckchain</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/admin/css/common.css" />
    <link rel="stylesheet" href="/layui/css/layui.css" />
</head>
<form class="layui-form" action="" enctype="multipart/form-data">
    <div class="layui-form user-info-form layui-text" style="max-width: 400px;padding-top: 25px;">
        <div class="layui-form-item">
            <label class="layui-form-label">记录文件:</label>
            <div class="layui-input-block">
                <input type="file" id="fileExcel" name="fileExcel" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">附件:</label>
            <div class="layui-input-block">
                <input type="file" name="attachment" id="attachment">
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

</body>

<script src="/layui/layui.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , $ = layui.jquery
            ,upload = layui.upload;




        //监听提交
        form.on('submit(user-save)', function (data) {
            /*$.post('https://test.ellipticcurve.com.cn:8083/baiwan/batchAddBaiWan', data.field, function (data1) {
                console.log("data111111111---------" + data1);
                if (data == "success") {
                    parent.layer.close(top.layerFrameConfig.iframeUserModify.layer_index);
                    parent.layer.msg("添加成功 ！")
                } else {
                    /!*layer.alert("添加失败 ！")*!/
                    parent.layer.close(top.layerFrameConfig.iframeUserModify.layer_index);
                    parent.layer.msg("添加失败 ！")
                }
            });*/
            var formData=new FormData();
            formData.append("fileExcel",$("#fileExcel")[0].files[0])
            formData.append("attachment",$("#attachment")[0].files[0])
            $.ajax({
                url: "https://test.ellipticcurve.com.cn:8083/baiwan/batchAddBaiWan",
                type: "post",
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                success: function (result) {
                    parent.layer.msg("添加成功 ！")
                },error: function (err) {
                    parent.layer.msg("添加失败 ！")
                }

            })


           /* $.ajax({
                url: "https://localhost:8083/baiwan/batchAddBaiWan",
                data: data.field,
                dataType: "jsonp",
                jsonp: "callback",				//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
                jsonpCallback: "jsonpCallback",	//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
                success: function (resdata, textStatus, jqXHRult) {
                    if (resdata != null) {
                        if (resdata.result) {
                            //成功处理
                            parent.layer.msg("添加成功 ！")
                        } else {
                            //失败处理
                            parent.layer.msg("添加失败 ！")
                        }
                    }
                },
                error: function () {
                    //错误处理
                }
            });*/
            return false;
        });


    });
</script>
</html>
